package pattern.observer.jdk;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.Observable;
import java.util.Observer;

@NoArgsConstructor
@AllArgsConstructor
public class WeixinUser implements Observer {
    private String name;
    /**
     * This method is called whenever the observed object is changed. An
     * application calls an <tt>Observable</tt> object's
     * <code>notifyObservers</code> method to have all the object's
     * observers notified of the change.
     *
     * @param o   the observable object.
     * @param arg an argument passed to the <code>notifyObservers</code>
     */
    @Override
    public void update(Observable o, Object arg) {
        System.out.println(name + "关注了公众号（被观察者）:" + ((Subject)o).getName() +
                "，接收到消息：" + arg);
    }
}
